package org.csu.onlineedubackend.controller;

import org.csu.onlineedubackend.result.CommonResponse;
import org.csu.onlineedubackend.result.ResponseCode;
import org.csu.onlineedubackend.service.StudentCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/student/center")
@CrossOrigin(origins = "*")
public class StudentCenterController {

    @Autowired
    private StudentCenterService studentCenterService;

    /**
     * 获取学生最近观看的课程
     * @param studentId 学生ID
     * @param limit 限制数量，默认为4
     * @return 课程列表
     */
    @GetMapping("/recent-courses")
    public CommonResponse getRecentCourses(@RequestParam Integer studentId, @RequestParam(defaultValue = "4") Integer limit) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getRecentCourses(studentId, limit));
    }

    /**
     * 获取学生活跃度数据
     * @param studentId 学生ID
     * @param days 天数，默认为7
     * @return 活跃度数据
     */
    @GetMapping("/activity")
    public CommonResponse getActivityData(@RequestParam Integer studentId, @RequestParam(defaultValue = "7") Integer days) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getActivityData(studentId, days));
    }

    /**
     * 获取学生学习进度分类数据
     * @param studentId 学生ID
     * @return 学习进度分类数据
     */
    @GetMapping("/progress-category")
    public CommonResponse getProgressCategoryData(@RequestParam Integer studentId) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getProgressCategoryData(studentId));
    }

    /**
     * 获取学生订阅但未完成的课程
     * @param studentId 学生ID
     * @param limit 限制数量，默认为4
     * @return 课程列表
     */
    @GetMapping("/subscribed-uncompleted")
    public CommonResponse getSubscribedUncompletedCourses(@RequestParam Integer studentId, @RequestParam(defaultValue = "4") Integer limit) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getSubscribedUncompletedCourses(studentId, limit));
    }

    /**
     * 获取学生订阅且已完成的课程
     * @param studentId 学生ID
     * @param limit 限制数量，默认为3
     * @return 课程列表
     */
    @GetMapping("/subscribed-completed")
    public CommonResponse getSubscribedCompletedCourses(@RequestParam Integer studentId, @RequestParam(defaultValue = "3") Integer limit) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getSubscribedCompletedCourses(studentId, limit));
    }

    /**
     * 获取学生收藏的课程
     * @param studentId 学生ID
     * @return 课程列表
     */
    @GetMapping("/liked-courses")
    public CommonResponse getLikedCourses(@RequestParam Integer studentId) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getLikedCourses(studentId));
    }

    /**
     * 获取所有订阅但未完成的课程
     * @param studentId 学生ID
     * @return 课程列表
     */
    @GetMapping("/all-subscribed-uncompleted")
    public CommonResponse getAllSubscribedUncompletedCourses(@RequestParam Integer studentId) {
        return CommonResponse.createForSuccess(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getDescription(), studentCenterService.getAllSubscribedUncompletedCourses(studentId));
    }
} 